package mint.modules;

import java.io.InputStream;
import java.util.Formatter;
import java.util.List;

import mint.MintLexer;
import mint.MintParser;

import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.CommonTokenStream;

public class SyntaxAnalizer {
	public static void parse(InputStream inputStream, Formatter output) throws Exception {
		MintLexer lexer = new MintLexer(new ANTLRInputStream(inputStream));		
		CommonTokenStream tokens = new CommonTokenStream(lexer);
		MintParser parser = new MintParser(tokens);
		parser.compilationUnit();
		
		List<String> errorList = parser.getErrorList();
		
		if (errorList.isEmpty())
			output.format("OK\n");
		else
			for(String err : errorList)
				output.format("%s\n", err);
	}

}
